package org.apmap.beans;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Flat")
@XmlRootElement
public class Flat extends Point {

    @XmlAttribute(required = true)
    protected long id;
    @XmlAttribute
    protected long userid;
    @XmlAttribute
    protected Double lng;
    @XmlAttribute
    protected Double lat;
    @XmlAttribute
    protected String type;
    @XmlAttribute
    protected String address;
    @XmlAttribute
    protected byte roomNumber;
    @XmlAttribute
    protected int square;
    @XmlAttribute
    protected byte floor;
    @XmlAttribute
    protected double price;
    @XmlAttribute
    protected String currency;
    @XmlAttribute
    protected String comment;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getUserid() {
        return userid;
    }

    public void setUserid(long userid) {
        this.userid = userid;
    }

    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public byte getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(byte roomNumber) {
        this.roomNumber = roomNumber;
    }

    public int getSquare() {
        return square;
    }

    public void setSquare(int square) {
        this.square = square;
    }

    public byte getFloor() {
        return floor;
    }

    public void setFloor(byte floor) {
        this.floor = floor;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public static void main(String[] args) throws Exception {
        javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext.newInstance(Flat.class);
        Flat flat = new Flat();
        flat.setAddress("ADR 1");
        flat.setLat(100.0);
        flat.setLng(200.0);

        Flat flat2 = new Flat();
        flat2.setAddress("ADR 2");
        flat2.setLat(300.0);
        flat2.setLng(400.0);

        javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(flat, System.out);
        marshaller.marshal(flat2, System.out);

//        String str = "<points><flatList id=\"3\" address=\"ADR 333\" lat=\"10.0\" lng=\"20.0\"/></points>";
//        javax.xml.bind.Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
//        points = (Points) unmarshaller.unmarshal(new ByteArrayInputStream(str.getBytes()));
//        System.out.println("points = " + points);
//        flat = points.getFlatList().get(0);
//        System.out.println("flat = " + flat.getLat());
//        System.out.println("flat = " + flat.getLng());



    }
}
